package com.test.config;

import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by liukx on 17.12.15 0015.
 */
@Configuration
public class ShiroConfig {

    @Bean
    public ShiroFilterFactoryBean shiroFilter(){
        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
        shiroFilterFactoryBean.setSecurityManager();
        shiroFilterFactoryBean.setLoginUrl();
        shiroFilterFactoryBean.setSuccessUrl();
        shiroFilterFactoryBean.setUnauthorizedUrl();
        return shiroFilterFactoryBean;
    }

    @Bean
    public SecurityManager securityManager(Realm shiroRealm){
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        securityManager.setRealm(shiroRealm);
    }

    @Bean
    public Realm shiroRealm(){
        return new ShiroRealm();
    }



}
